package tankgame02;

import java.util.Vector;

public class MyTank extends Tank {
	//我方坦克类
	//定义一个shot对象，表示一个射击（线程）
	Shot shot = null;
	//可以发射多颗子弹
	Vector<Shot> shots = new Vector<>();
	public MyTank(int x, int y) {
		super(x, y);
	}

	public void shotEnemyTank() {
		//创建shot对象，根据当前tank对象的位置和方向来创建shot
		switch (getDirection()) {
			case 0://上
			{
				shot = new Shot(getX() + 20, getY(), 0);
				break;
			}
			case 1://右
			{
				shot = new Shot(getX() + 60, getY() + 20, 1);
				break;
			}
			case 2://下
			{
				shot = new Shot(getX() + 20, getY() + 60, 2);
				break;
			}
			case 3://左
			{
				shot = new Shot(getX(), getY() + 20, 3);
				break;
			}
		}
		//把新建的子弹加入到vector集合中
		shots.add(shot);
		//启动射击线程
		new Thread(shot).start();
	}
}
